We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

<?=$this->action('action', 'controller') ?> equivalent in phalcon?

I have a header which has it's own controller and action, I want to include it in my view. we could do this with <?=$this->action('index', 'header') ?> with Zend. I couldn't find any equivalents in Phalcon. Would apreciate for any help.

Assuming you want to implement a helper.

There are two ways to do this:

1 - Make a library and call statically

LIBRARY:

<?php 

class MyClass{

    public function returnFalse() {

        return false;

    }

}

VIEW


if(MyClass::returnFalse()) {
    // Do Something
}

Make sure to auto load it.

OR

2 - Dependency injector

    $di->set('helper', function(){
        return (object) array(
            'my_class' => new MyClass();
        );
    });

VIEW


if($this->helper->my_class->returnFalse()) {
    // Do Something
}